package com.lhxm2.action;

import com.lhxm2.dto.UserFunsDTO;
import com.lhxm2.service.MyselfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class MyselfController {
    @Autowired
    private MyselfService myselfService;

    @RequestMapping("/myself/findfuns")
    @ResponseBody
    public Map<String,Object> findfuns(@RequestParam(value = "userid",defaultValue = "-1")int userid){
        Map<String,Object> map = new HashMap<>();
        if (userid==-1){
            map.put("code",1);
            map.put("msg","noUserId");
        }else {
            List<UserFunsDTO> list = myselfService.findfuns(userid);
            if (list!=null){
                map.put("code",0);
                map.put("msg","success");
                map.put("users",list);
            }else {
                map.put("code",1);
                map.put("msg","default");
            }
        }

        return map;
    }
}
